
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.



#ifndef __MATHLIB__H_INCLUDED__
#define __MATHLIB__H_INCLUDED__
#include <math.h>

namespace re //only re for easier access since this is really often used
{
	template<class T>
	class Vector2
	{
	public:
		Vector2()
		{
			x = 0; y = 0;
		}
		Vector2(T x_, T y_)
		{
			x = x_; y = y_;
		}
		Vector2(const Vector2& vec)
		{
			x = vec.x;
			y = vec.y;
		}

		Vector2& operator=(const Vector2& secondary)
		{
			this->x = secondary.x;
			this->y = secondary.y;
			return *this;
		}
		Vector2 operator+(const Vector2& secondary) const
		{
			Vector2 result;
			result.x = this->x + secondary.x;
			result.y = this->y + secondary.y;
			return result;
		}
		Vector2 operator-(const Vector2& secondary) const
		{
			Vector2 result;
			result.x = this->x - secondary.x;
			result.y = this->y - secondary.y;
			return result;
		}
		Vector2 operator*(const Vector2& secondary) const
		{
			Vector2 result;
			result.x = this->x * secondary.x;
			result.y = this->y * secondary.y;
		}
		Vector2 operator/(const Vector2& secondary) const
		{
			Vector2 result;
			result.x = this->x / secondary.x;
			result.y = this->y / secondary.y;
		}
		float GetLength() const
		{
			return sqrt(x*x+y*y);
		}
		void Normalize()
		{
			float len = GetLength();
			x /= len;
			y /= len;
		}
		Vector2 GetNormalized() const
		{
			float len = GetLength();
			Vector2 result;
			result.x = x / len;
			result.y = y / len;
			return result;
		}
		T x,y;
	};
	typedef Vector2<int> Vector2i;
	typedef Vector2<float> Vector2f;
	typedef Vector2<double> Vector2d;							
}

#endif